home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / emcs1855 / emcs1855.0 / lisp / ada.elc < prev    next >
Encoding:
Text File  |  1988-04-11  |  16.0 KB  |  201 lines

  1.  
  2. (setq auto-mode-alist (cons (cons "\\.ada$" (quote ada-mode)) auto-mode-alist))
  3.  
  4. (defvar ada-mode-syntax-table nil "\
  5. Syntax table in use in Ada-mode buffers.")
  6.  
  7. (let ((table (make-syntax-table))) (modify-syntax-entry 95 "_" table) (modify-syntax-entry 35 "_" table) (modify-syntax-entry 40 "()" table) (modify-syntax-entry 41 ")(" table) (modify-syntax-entry 36 "." table) (modify-syntax-entry 42 "." table) (modify-syntax-entry 47 "." table) (modify-syntax-entry 43 "." table) (modify-syntax-entry 45 "." table) (modify-syntax-entry 61 "." table) (modify-syntax-entry 38 "." table) (modify-syntax-entry 124 "." table) (modify-syntax-entry 60 "." table) (modify-syntax-entry 62 "." table) (modify-syntax-entry 91 "." table) (modify-syntax-entry 93 "." table) (modify-syntax-entry 123 "." table) (modify-syntax-entry 125 "." table) (modify-syntax-entry 46 "." table) (modify-syntax-entry 92 "." table) (modify-syntax-entry 58 "." table) (modify-syntax-entry 59 "." table) (modify-syntax-entry 39 "." table) (modify-syntax-entry 34 "\"" table) (setq ada-mode-syntax-table table))
  8.  
  9. (defvar ada-mode-map nil "\
  10. Keymap used in Ada mode.")
  11.  
  12. (let ((map (make-sparse-keymap))) (define-key map "
  13. " (quote ada-newline)) (define-key map "" (quote backward-delete-char-untabify)) (define-key map "    " (quote ada-tab)) (define-key map "⇨    " (quote ada-untab)) (define-key map "⇨<" (quote ada-backward-to-same-indent)) (define-key map "⇨>" (quote ada-forward-to-same-indent)) (define-key map "⇨h" (quote ada-header)) (define-key map "⇨(" (quote ada-paired-parens)) (define-key map "⇨-" (quote ada-inline-comment)) (define-key map "⇨⇧" (quote ada-array)) (define-key map "⇨b" (quote ada-exception-block)) (define-key map "⇨d" (quote ada-declare-block)) (define-key map "⇨❎" (quote ada-exception)) (define-key map "⇨c" (quote ada-case)) (define-key map "⇨♪" (quote ada-package-spec)) (define-key map "⇨k" (quote ada-package-body)) (define-key map "⇨⓪" (quote ada-procedure-spec)) (define-key map "⇨p" (quote ada-subprogram-body)) (define-key map "⇨╱" (quote ada-function-spec)) (define-key map "⇨f" (quote ada-for-loop)) (define-key map "⇨l" (quote ada-loop)) (define-key map "⇨i" (quote ada-if)) (define-key map "⇨I" (quote ada-elsif)) (define-key map "⇨e" (quote ada-else)) (define-key map "⇨⑥" (quote ada-private)) (define-key map "⇨②" (quote ada-record)) (define-key map "⇨③" (quote ada-subtype)) (define-key map "⇨s" (quote ada-separate)) (define-key map "⇨④" (quote ada-type)) (define-key map "⇨t" (quote ada-tabsize)) (define-key map "⇨w" (quote ada-while-loop)) (define-key map "⇨⑦" (quote ada-when)) (define-key map "⇨x" (quote ada-exit)) (define-key map "⇨C" (quote ada-compile)) (define-key map "⇨B" (quote ada-bind)) (define-key map "⇨E" (quote ada-find-listing)) (define-key map "⇨L" (quote ada-library-name)) (define-key map "⇨O" (quote ada-options-for-bind)) (setq ada-mode-map map))
  14.  
  15. (defvar ada-indent 4 "\
  16. *Value is the number of columns to indent in Ada-Mode.")
  17.  
  18. (defun ada-mode nil "\
  19. This is a mode intended to support program development in Ada.
  20. Most control constructs and declarations of Ada can be inserted in the buffer
  21. by typing Control-C followed by a character mnemonic for the construct.
  22.  
  23. C-c C-a  array             C-c b    exception block
  24. C-c C-e  exception      C-c d    declare block
  25. C-c C-k  package spec   C-c k    package body
  26. C-c C-p  procedure spec C-c p    proc/func body
  27. C-c C-f  func spec      C-c f    for loop
  28.                         C-c i    if
  29.                         C-c I    elsif
  30.                         C-c e    else
  31. C-c C-v  private        C-c l    loop
  32. C-c C-r  record         C-c c    case
  33. C-c C-s  subtype        C-c s    separate
  34. C-c C-t  type           C-c t    tab spacing for indents
  35. C-c C-w  when           C-c w    while
  36.                         C-c x    exit
  37. C-c (    paired parens  C-c -    inline comment
  38.                         C-c h    header sec
  39. C-c C    compile        C-c B    bind
  40. C-c E    find error list
  41. C-c L    name library   C-c O    options for bind
  42.  
  43. C-c < and C-c > move backward and forward respectively to the next line
  44. having the same (or lesser) level of indentation.
  45.  
  46. Variable ada-indent controls the number of spaces for indent/undent.
  47.  
  48. \\{ada-mode-map}
  49. " (interactive) (byte-code "עêפ êצ✓!êקë①êרë②êשב!êתë③êשג!êןë④êך
  50. !êשה!êם◆Pë⑥╱êשז!ê╱ë⑥✓êשח!êטë⑥    êשי!êטë⑥♪êשכ!êףë⑥ êשל!êץë⑥
  51. êשב!êתë③êשמ!ê§ë⑥êשנ!ê∧ë⑥êשס!êטë⑥⓪ê∞α!ç" [ada-mode-map major-mode mode-name comment-column end-comment-column ada-mode-syntax-table paragraph-start page-delimiter paragraph-separate paragraph-ignore-fill-prefix t require-final-newline comment-start comment-end comment-start-skip comment-indent-hook parse-sexp-ignore-comments nil kill-all-local-variables use-local-map ada-mode "Ada" make-local-variable 41 72 set-syntax-table "^$\\|" "--" "
  52. " "--+ *" c-comment-indent run-hooks ada-mode-hook] 17))
  53.  
  54. (defun ada-tabsize (s) "\
  55. changes spacing used for indentation. Reads spacing from minibuffer." (interactive "nnew indentation spacing: ") (byte-code "אê    ë⓪ç" [ada-indent s nil] 2))
  56.  
  57. (defun ada-newline nil "\
  58. Start new line and indent to current tab stop." (interactive) (byte-code "IJêא ⑧ב ê✓j)ç" [ada-cc nil current-indentation newline] 3))
  59.  
  60. (defun ada-tab nil "\
  61. Indent to next tab stop." (interactive) (byte-code "IJêאבג ✓\"T✓\"jç" [ada-indent nil * / current-indentation] 5))
  62.  
  63. (defun ada-untab nil "\
  64. Delete backwards to previous tab stop." (interactive) (byte-code "IJêא✓IJ\"ç" [ada-indent nil backward-delete-char-untabify] 3))
  65.  
  66. (defun ada-go-to-this-indent (step indent-level) "\
  67. Move point repeatedly by <step> lines till the current line
  68. has given indent-level or less, or the start/end of the buffer is hit.
  69. Ignore blank lines, statement labels, block/loop names." (byte-code "בג✓!!à$דה!å$דו!å$דז!å$דח!å$ט     Và,אêéç" [step indent-level nil zerop forward-line looking-at "^[     ]*$" "^[     ]*--" "^<<[A-Za-z0-9_]+>>" "^[A-Za-z0-9_]+:" current-indentation] 9))
  70.  
  71. (defun ada-backward-to-same-indent nil "\
  72. Move point backwards to nearest line with same indentation or less.
  73. If not found, point is left at top of buffer." (interactive) (byte-code "ijêIJאב \"êג ç" [nil ada-go-to-this-indent -1 current-indentation back-to-indentation] 4))
  74.  
  75. (defun ada-forward-to-same-indent nil "\
  76. Move point forwards to nearest line with same indentation or less.
  77. If not found, point is left at start of last line in buffer." (interactive) (byte-code "ijêIJאב \"êג ç" [nil ada-go-to-this-indent 1 current-indentation back-to-indentation] 4))
  78.  
  79. (defun ada-array nil "\
  80. Insert array type definition, prompting for component type,
  81. leaving the user to type in the index subtypes." (interactive) (byte-code "ijêIJcêא êבג!cêד êהcêא êבו!cêד ç" [nil "array ()" backward-char read-string "index subtype[s]: " end-of-line " of ;" "component-type: "] 7))
  82.  
  83. (defun ada-case nil "\
  84. Build skeleton case statment, prompting for the selector expression.
  85. starts up the first when clause, too." (interactive) (byte-code "ijêIJcêאבג!ד\"êה êה êוcêזח!êט êט êי ç" [nil "case " insert read-string "selector expression: " " is" ada-newline "end case;" end-of-line 0 ada-tab ada-when] 9))
  86.  
  87. (defun ada-declare-block nil "\
  88. Insert a block with a declare part and indent for the 1st declaration." (interactive) (byte-code "IJêאב!⑧גcêד✓ה\"?à#ו êזח!êט✓י\"êכח!êל êמ êמ êנcêמ êמ êד✓ה\"â?סcéDטע✓פ#)êלצ!êק ç" [ada-block-name nil read-string "[block name]: " "declare" string-equal "" beginning-of-line open-line 1 insert ":" next-line end-of-line ada-newline "begin" "end;" "end " ";" -2 ada-tab] 16))
  89.  
  90. (defun ada-exception-block nil "\
  91. Insert a block with an exception part and indent for the 1st line of code." (interactive) (byte-code "אêבג!⑧דcêה✓ו\"?à#ז êחט!êי✓כ\"êלט!êמ êנ êנ êסcêנ êנ êה✓ו\"â?עcéDיפ✓צ#)êמק!êר ç" [block-name t nil read-string "[block name]: " "begin" string-equal "" beginning-of-line open-line 1 insert ":" next-line end-of-line ada-newline "exception" "end;" "end " ";" -2 ada-tab] 16))
  92.  
  93. (defun ada-exception nil "\
  94. Undent and insert an exception part into a block. Reindent." (interactive) (byte-code "ijêIJ êאcêב êג ç" [nil ada-untab "exception" ada-newline ada-tab] 4))
  95.  
  96. (defun ada-else nil "\
  97. Add an else clause inside an if-then-end-if clause." (interactive) (byte-code "ijêIJ êאcêב êג ç" [nil ada-untab "else" ada-newline ada-tab] 4))
  98.  
  99. (defun ada-exit nil "\
  100. Insert an exit statement, prompting for loop name and condition." (interactive) (byte-code "אêבcêגד!⑧ה✓ו\"?à⑤זח✓\")êגט!⑨ה    ו\"?à5יכ    \"â1זח    \"é5זל    \")êמcç" [ada-loop-name ada-exit-condition nil "exit" read-string "[name of loop to exit]: " string-equal "" insert " " "[exit condition]: " string-match "^ *[Ww][Hh][Ee][Nn] +" " when " ";"] 10))
  101.  
  102. (defun ada-when nil "\
  103. Start a case statement alternative with a when clause." (interactive) (byte-code "ijêIJ êאcêבגד!ה\"êו êז ç" [nil ada-untab "when " insert read-string "'|'-delimited choice list: " " =>" ada-newline ada-tab] 6))
  104.  
  105. (defun ada-for-loop nil "\
  106. Build a skeleton for-loop statement, prompting for the loop parameters." (interactive) (byte-code "אêבcêגד!⑧ה✓ו\"?⑨    à&ז êחט!êי✓כ\"êלט!êמט!êיגנ!ס\"êיגע!פ\"êצ êצ êקcê    àFיר✓\"êשc*êמת!êן ç" [ada-loop-name ada-loop-is-named nil "for " read-string "[loop name]: " string-equal "" beginning-of-line open-line 1 insert ":" next-line end-of-line "loop variable: " " in " "range: " " loop" ada-newline "end loop" " " ";" 0 ada-tab] 17))
  107.  
  108. (defun ada-header nil "\
  109. Insert a comment block containing the module title, author, etc." (interactive) (byte-code "ijêIJcêאב!cêגדה \"êגוז \"êגחט יכ ל%ç" [nil "--
  110. --  Title:     " read-string "Title: " insert "
  111. --  Created:    " current-time-string "
  112. --  Author:     " user-full-name "
  113. --        <" user-login-name "@" system-name ">
  114. --
  115. "] 13))
  116.  
  117. (defun ada-if nil "\
  118. Insert skeleton if statment, prompting for a boolean-expression." (interactive) (byte-code "ijêIJcêאבג!ד\"êה êה êוcêזח!êט ç" [nil "if " insert read-string "condition: " " then" ada-newline "end if;" end-of-line 0 ada-tab] 7))
  119.  
  120. (defun ada-elsif nil "\
  121. Add an elsif clause to an if statement, prompting for the boolean-expression." (interactive) (byte-code "ijêIJ êאcêבגד!ה\"êו êז ç" [nil ada-untab "elsif " insert read-string "condition: " " then" ada-newline ada-tab] 6))
  122.  
  123. (defun ada-loop nil "\
  124. insert a skeleton loop statement.  exit statement added by hand." (interactive) (byte-code "אêבcêגד!⑧ה✓ו\"?⑨    à&ז êחט!êי✓כ\"êלט!êמט!êנ êנ êסcê    à8יע✓\"êפc*êמצ!êק ç" [ada-loop-name ada-loop-is-named nil "loop " read-string "[loop name]: " string-equal "" beginning-of-line open-line 1 insert ":" forward-line end-of-line ada-newline "end loop" " " ";" 0 ada-tab] 13))
  125.  
  126. (defun ada-package-spec nil "\
  127. Insert a skeleton package specification." (interactive) (byte-code "IJêאcêבג!⑧ד✓ה\"êו êו êדז✓ח#êטי!êכ )ç" [ada-package-name nil "package " read-string "package name: " insert " is" ada-newline "end " ";" end-of-line 0 ada-tab] 8))
  128.  
  129. (defun ada-package-body nil "\
  130. Insert a skeleton package body --  includes a begin statement." (interactive) (byte-code "IJêאcêבג!⑧ד✓ה\"êו êו êזcêו êדח✓ט#êיכ!êל )ç" [ada-package-name nil "package body " read-string "package name: " insert " is" ada-newline "begin" "end " ";" end-of-line -1 ada-tab] 9))
  131.  
  132. (defun ada-private nil "\
  133. Undent and start a private section of a package spec. Reindent." (interactive) (byte-code "ijêIJ êאcêב êג ç" [nil ada-untab "private" ada-newline ada-tab] 4))
  134.  
  135. (defun ada-get-arg-list nil "\
  136. Read from user a procedure or function argument list.
  137. Add parens unless arguments absent, and insert into buffer.
  138. Individual arguments are arranged vertically if entered one-at-a-time.
  139. Arguments ending with ';' are presumed single and stacked." (byte-code "אcêiבג!⑨⑧ד    ה\"â⑥וז!é4חט    \"à/    cêי ê✓jêבכ!ë①êé⑥êל    מ\"*ç" [ada-arg-indent ada-args " (" read-string "[arguments]: " string-equal "" backward-delete-char 2 string-match ";$" newline "next argument: " insert ")"] 9))
  140.  
  141. (defun ada-function-spec nil "\
  142. Insert a function specification.  Prompts for name and arguments." (interactive) (byte-code "ijêIJcêאב!cêג êדcêאה!cç" [nil "function " read-string "function name: " ada-get-arg-list " return " "result type: "] 4))
  143.  
  144. (defun ada-procedure-spec nil "\
  145. Insert a procedure specification, prompting for its name and arguments." (interactive) (byte-code "ijêIJcêאב!cêג ç" [nil "procedure " read-string "procedure name: " ada-get-arg-list] 3))
  146.  
  147. (defun get-ada-subprogram-name nil "\
  148. Return (without moving point or mark) a pair whose CAR is
  149. the name of the function or procedure whose spec immediately precedes point,
  150. and whose CDR is the column nbr the procedure/function keyword was found at." (byte-code "èג⑧דהIJא#â4וז!å④וח!â/ië⓪êטי!ê`טכ!êל`♪\"✓B)é1מ é7נ✓B))ç" [ada-proc-indent nil t p2 0 re-search-backward "[PpFf][RrUu][OoNn][Cc][EeTt][DdIi][UuOo][RrNn]" looking-at "\\<[Pp][Rr][Oo][Cc][Ee][Dd][Uu][Rr][Ee]\\>" "\\<[Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn]\\>" forward-word 2 -1 buffer-substring get-ada-subprogram-name "NAME?"] 9))
  151.  
  152. (defun ada-subprogram-body nil "\
  153. Insert frame for subprogram body.
  154. Invoke right after ada-function-spec or ada-procedure-spec." (interactive) (byte-code "IJêאcêב ⑧ג ê✓Ajêד êהcêד êד êוז✓@ח#)êטי!êכ ç" [ada-subprogram-name-col nil " is" get-ada-subprogram-name newline ada-newline "begin" insert "end " ";" end-of-line -2 ada-tab] 9))
  155.  
  156. (defun ada-separate nil "\
  157. Finish a body stub with 'is separate'." (interactive) (byte-code "ijêIJcêא êב êגcêא êד ç" [nil " is" ada-newline ada-tab "separate;" ada-untab] 5))
  158.  
  159. (defun ada-record nil "\
  160. Insert a skeleton record type declaration." (interactive) (byte-code "ijêIJcêא êא êבcêגד!êה ç" [nil "record" ada-newline "end record;" end-of-line 0 ada-tab] 5))
  161.  
  162. (defun ada-subtype nil "\
  163. Start insertion of a subtype declaration, prompting for the subtype name." (interactive) (byte-code "ijêIJאבג!ד#êה êוז!ç" [nil insert "subtype " read-string "subtype name: " " is ;" backward-char message "insert subtype indication."] 5))
  164.  
  165. (defun ada-type nil "\
  166. Start insertion of a type declaration, prompting for the type name." (interactive) (byte-code "IJêאבגד!\"êגה!⑧ו✓ז\"?àəאח✓ט#)êיcêכל!ç" [disc-part nil insert "type " read-string "type name: " "discriminant specs: " string-equal "" "(" ")" " is " message "insert type definition."] 8))
  167.  
  168. (defun ada-while-loop nil (interactive) (byte-code "אêבcêגד!⑧ה✓ו\"?⑨    à&ז êחט!êי✓כ\"êלט!êמט!êיגנ!ס\"êע êע êפcê    à?יצ✓\"êקc*êמר!êש ç" [ada-loop-name ada-loop-is-named nil "while " read-string "loop name: " string-equal "" beginning-of-line open-line 1 insert ":" next-line end-of-line "entry condition: " " loop" ada-newline "end loop" " " ";" 0 ada-tab] 15))
  169.  
  170. (defun ada-paired-parens nil "\
  171. Insert a pair of round parentheses, placing point between them." (interactive) (byte-code "ijêIJcêא ç" [nil "()" backward-char] 2))
  172.  
  173. (defun ada-inline-comment nil "\
  174. Start a comment after the end of the line, indented at least COMMENT-COLUMN.
  175. If starting after END-COMMENT-COLUMN, start a new line." (interactive) (byte-code "אêב êi✓Và
  176. ג êi    Wà⑥    jêדcç" [end-comment-column comment-column nil end-of-line newline " -- "] 4))
  177.  
  178. (defun ada-display-comment nil "\
  179. Inserts 3 comment lines, making a display comment." (interactive) (byte-code "ijêIJcêאב!ç" [nil "--
  180. -- 
  181. --" end-of-line 0] 2))
  182.  
  183. (defvar ada-lib-dir-name "lib" "\
  184. *Current ada program library directory.")
  185.  
  186. (defvar ada-bind-opts "" "\
  187. *Options to supply for binding.")
  188.  
  189. (defun ada-library-name (ada-lib-name) "\
  190. Specify name of ada library directory for later compilations." (interactive "Dname of ada library directory: ") (byte-code "אê    ë⓪ç" [ada-lib-dir-name ada-lib-name nil] 2))
  191.  
  192. (defun ada-options-for-bind nil "\
  193. Specify options, such as -m and -i, needed for adabind." (byte-code "IJא!ë⓪ç" [ada-bind-opts read-string "-m and -i options for adabind: "] 3))
  194.  
  195. (defun ada-compile (ada-prefix-arg) "\
  196. Save the current buffer and compile it into the current program library.
  197. Initialize the library if a prefix arg is given." (interactive "P") (byte-code "גê    ?â♪דé ה⑧ו əזחט✓י♪כ
  198. &╱!*ç" [ada-init ada-prefix-arg ada-source-file ada-lib-dir-name nil "" "-n " buffer-name compile concat "adacomp " "-l " " "] 9))
  199.  
  200. (defun ada-find-listing nil "\
  201. Find listing file for ada source in current buffer, using other window." (interactive) (byte-code "ijêIJא בגOדP!êהו!ç" [nil find-file-other-window buffer-name 0 -4 ".lis" search-forward "*** ERROR"] 5))
  202.  
  203. (defun ada-bind nil "\
  204. Bind the current program library, using the current binding options." (interactive) (byte-code "אêבג✓ד    R!ç" [ada-bind-opts ada-lib-dir-name nil compile "adabind " " "] 5))
  205.